﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Tormenta.Utils.Animation;
using Microsoft.Xna.Framework;

namespace Tormenta.Utils.Menu
{
    public class MenuItemBase
    {
        #region .ctr
        public MenuItemBase(int value, string name, Vector2 position, Texture2D dysplayImage, Texture2D focusImage, Texture2D clickImage)
        {
            this.Value = value;
            this.Name = name;
            this.Position = position;

            List<Texture2D> lst = new List<Texture2D>();
            lst.Add(dysplayImage);
            lst.Add(focusImage);
            lst.Add(clickImage);
            this.Animation = new SimpleAnimation(lst);
        } 
        #endregion

        #region Properties

        public string Name { get; set; }

        public int Value { get; set; }

        public SimpleAnimation Animation { get; set; }

        public Vector2 Position { get; set; }

        #endregion

        #region Methods

        public virtual void ClearClick()
        {
            this.Animation.Previous();
        }

        public virtual void ClearFocus()
        {
            this.Animation.Previous();
        }

        public virtual void OnFocus()
        {
            this.Animation.Next();
        }

        public virtual void OnClick()
        {
            this.Animation.Next();
            if (this.Click != null)
                this.Click(this, new EventArgs());
        }

        public virtual void Draw(SpriteBatch spriteBatch, Vector2 parentPosition)
        {
            spriteBatch.Draw(this.Animation.CurrentSprite, parentPosition + this.Position, Util.TRANSPARENT_COLOR);
        }

        #endregion

        #region Events

        public event EventHandler Click;

        #endregion

    }
}
